angular.module('DataServiceModule', ['UtilityModule']).factory('stock', function ($http, log) {
    var service = {
        getData: function () {
            var url = 'http://query.yahooapis.com/v1/public/yql?format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&q=';
            var query = encodeURIComponent('select * from yahoo.finance.quote where symbol in ("AAPL","IBM","MSFT","HPQ")');

            return $http.get(url + query).then(function (result) {
                                            log.info('Call stock:' + status);
                                            log.debug(result);
                                            return { status: true, data: result };
                                        },
                                        function (error) {
                                            log.error('Call stock:' + status);
                                            log.debug(error);
                                            return { status: false, data: null };
                                        });
        }
    }

    return service;
}).factory('weather', function ($http, log) {
    var service = {
        getData: function () {
            var url = 'http://query.yahooapis.com/v1/public/yql?format=json&diagnostics=true&q=';
            var query = encodeURIComponent('select * from weather.forecast where woeid = 2151849');

            return $http.get(url + query).then(function (result) {
                                            log.info('Call weather:' + status);
                                            log.debug(result);
                                            return { status: true, data: result };
                                        },
                                        function (error) {
                                            log.error('Call weather:' + status);
                                            log.debug(error);
                                            return { status: false, data: null };
                                        });
        }
    };
    return service;
});